package cn.nohan.funplay.module.member.mongo.config;

import com.mongoplus.handlers.TypeHandler;
import com.mongoplus.model.geo.Coordinate;
import org.bson.Document;
import org.springframework.stereotype.Component;

/**
 * @author caozhipeng
 * @date 2025/7/31
 */
@Component
public class CoordinateTypeHandler implements TypeHandler<Coordinate> {
    @Override
    public Object setParameter(String fieldName, Coordinate obj) {
        return obj;
    }

    @Override
    public Coordinate getResult(Object obj) {
        Document document=(Document)obj;
        return new Coordinate(document.getDouble("x"),document.getDouble("y"));
    }
}
